
package com.wanmait.hr.filter;

import com.wanmait.hr.service.Impl.UserServiceImpl;
import com.wanmait.hr.vo.Department;
import com.wanmait.hr.vo.User;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
@WebFilter("/manage/personnelChanges/*")
public class SessionFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest)servletRequest;

        HttpSession session = req.getSession();

        Object obj = session.getAttribute("user");
        if (obj==null)
        {
            User user=new User();
            Department dt=new Department();
            dt.setId(2);
            user.setId(27);
            user.setIsHr(false);
            user.setIsSys(2);
            user.setName("陈正儒");
            user.setDt(dt);
            session.setAttribute("user",user);
            filterChain.doFilter(servletRequest, servletResponse);
            return;
        }
        else {
            filterChain.doFilter(servletRequest, servletResponse);
            return;
        }

    }
}

